@file:JvmName("KotlinUtils")
package com.example.core.utils

import android.util.TypedValue
import android.widget.Toast
import com.example.core.BaseApplication

/**
 *
 * 作者： JairusTse
 * 日期： 2021/2/4
 */
object Utils {

    private val displayMetrics = android.content.res.Resources.getSystem()
    .displayMetrics

    fun dp2px(dp: Float): Float{
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics)
    }

    fun toast(string: String) {
        toast(string, Toast.LENGTH_SHORT)
    }

    fun toast(string: String, duration: Int) {
        Toast.makeText(BaseApplication.currentApplication(), string, duration).show()
    }
}